using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public static class SkillTool 
{
    /// <summary>
    /// 图层检测
    /// </summary>
    /// <param name="obj"></param>
    /// <param name="layermask"></param>
    /// <returns></returns>
    static public bool IsInLayerMask(GameObject obj, LayerMask layermask)
    {
        return ((1 << obj.layer) & layermask) != 0;
    }

    /// <summary>
    /// 获取实体的中心点
    /// </summary>
    /// <param name="deployer"></param>
    /// <returns></returns>
    public static Vector3 GetCharacterCenterPos(Transform deployer)
    {
        CapsuleCollider2D collider = deployer.GetComponent<CapsuleCollider2D>();

        // 获取碰撞体的局部中心点
        Vector3 localCenter = collider.offset;
        // 加上碰撞体高度的一半，得到中心位置
        //localCenter.y += collider.size.y / 2f;

        // 转换到世界坐标
        Vector3 worldCenter = deployer.TransformPoint(localCenter);

        return worldCenter;
    }
}
